package org.neuedu.servlet;

import org.neuedu.bean.Detail;
import org.neuedu.service.ArticleService;
import org.neuedu.service.ArticleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "ArticleDetailServlet",urlPatterns = "/article/detail")
public class ArticleDetailServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String aid = request.getParameter("aid");
        ArticleService service = new ArticleServiceImpl();
        Detail detail = service.getArticleDetailById(Integer.valueOf(aid));
        // 文章详情+作者信息+评论量+本周热议
        request.setAttribute("detailInfo",detail);
        request.getRequestDispatcher("/WEB-INF/jsp/jie/detail.jsp").forward(request,response);
    }
}
